package forum.communication;

import forum.server.controller.ForumFacadeInt;
import forum.server.exceptions.DatabaseException;
import forum.server.exceptions.NoSuchPostException;

public class SearchResultView extends ClientMessage{

	/**
	 * 
	 */
	private static final long serialVersionUID = -5399317748700122035L;
	private int postID;
	
	public SearchResultView(int pID){
		this.postID = pID;
	}
	
	@Override
	public ServerResponse doOperation(ForumFacadeInt forum) {
		
		try {
			return new ServerResponse(forum.encodeOneResult(postID), true);
		} catch (DatabaseException e) {
			return new ServerResponse(e.getMessage(), false);
		} catch (NoSuchPostException e) {
			return new ServerResponse(e.getMessage(), false);
		}
		
		
	}

}
